package com.ruoyi.system.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.hbs.domain.MsfxTerminalSalesFirstOrder;
import com.ruoyi.hbs.service.MsfxTerminalSalesFirstOrderService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * msfx—终端销售首单Controller
 * 
 * @author wl
 * @date 2025-11-18
 */
@RestController
@RequestMapping("/hbs/msfxTerminalSalesFirstOrder")
public class MsfxTerminalSalesFirstOrderController extends BaseController
{
    @Autowired
    private MsfxTerminalSalesFirstOrderService msfxTerminalSalesFirstOrderService;

    /**
     * 查询msfx—终端销售首单列表
     */
    @PreAuthorize("@ss.hasPermi('hbs:msfxTerminalSalesFirstOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(MsfxTerminalSalesFirstOrder msfxTerminalSalesFirstOrder)
    {
        startPage();
        List<MsfxTerminalSalesFirstOrder> list = msfxTerminalSalesFirstOrderService.selectMsfxTerminalSalesFirstOrderList(msfxTerminalSalesFirstOrder);
        return getDataTable(list);
    }

    /**
     * 导出msfx—终端销售首单列表
     */
    @PreAuthorize("@ss.hasPermi('hbs:msfxTerminalSalesFirstOrder:export')")
    @Log(title = "msfx—终端销售首单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MsfxTerminalSalesFirstOrder msfxTerminalSalesFirstOrder)
    {
        List<MsfxTerminalSalesFirstOrder> list = msfxTerminalSalesFirstOrderService.selectMsfxTerminalSalesFirstOrderList(msfxTerminalSalesFirstOrder);
        ExcelUtil<MsfxTerminalSalesFirstOrder> util = new ExcelUtil<MsfxTerminalSalesFirstOrder>(MsfxTerminalSalesFirstOrder.class);
        util.exportExcel(response, list, "msfx—终端销售首单数据");
    }

    /**
     * 获取msfx—终端销售首单详细信息
     */
    @PreAuthorize("@ss.hasPermi('hbs:msfxTerminalSalesFirstOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(msfxTerminalSalesFirstOrderService.getById(id));
    }

    /**
     * 新增msfx—终端销售首单
     */
    @PreAuthorize("@ss.hasPermi('hbs:msfxTerminalSalesFirstOrder:add')")
    @Log(title = "msfx—终端销售首单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MsfxTerminalSalesFirstOrder msfxTerminalSalesFirstOrder)
    {
        return toAjax(msfxTerminalSalesFirstOrderService.save(msfxTerminalSalesFirstOrder));
    }

    /**
     * 修改msfx—终端销售首单
     */
    @PreAuthorize("@ss.hasPermi('hbs:msfxTerminalSalesFirstOrder:edit')")
    @Log(title = "msfx—终端销售首单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MsfxTerminalSalesFirstOrder msfxTerminalSalesFirstOrder)
    {
        return toAjax(msfxTerminalSalesFirstOrderService.updateById(msfxTerminalSalesFirstOrder));
    }

    /**
     * 删除msfx—终端销售首单
     */
    @PreAuthorize("@ss.hasPermi('hbs:msfxTerminalSalesFirstOrder:remove')")
    @Log(title = "msfx—终端销售首单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(msfxTerminalSalesFirstOrderService.removeBatchByIds(Arrays.asList(ids)));
    }
}
